/**   
 * @Title: PageVo.java 
 * @Package com.org.framework.vo 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author cssuger@163.com   
 * @date 2017年1月22日 下午4:59:02 
 * @version V1.0   
 */
package com.bicon.base.data.common.vo;

import java.util.List;

import com.bicon.base.data.common.tools.JsonUtil;

/** 
 *@ClassName: PageVo 
 *@Description: TODO(这里用一句话描述这个类的作用) 
 *@author cssuger@163.com 
 *@date 2017年1月22日 下午4:59:02  
 */
public class PageVo<T> implements java.io.Serializable{

	/** 
	* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) 
	*/ 
	private static final long serialVersionUID = 6153648239782567369L;
	
	private int pageNow;
	
	private int pageSize;
	
	private long rows;
	
	private int pageTotal;
	
	private List<T> list;
	
	private T params;
	
	private boolean isexport ;//默认分页， 不导出
	
	
	public PageVo(int pageNow,int pageSize, T params){
		this.pageNow = pageNow;
		this.pageSize = pageSize;
		this.params = params;
		this.isexport = false;
	}
	
	public PageVo(int pageNow,int pageSize,long rows, T params){
		this.pageNow = pageNow;
		this.pageSize = pageSize;
		this.params = params;
		this.rows = rows;
		//计算共多少页
		this.pageTotal = builderPageTotal(pageSize,rows);
		this.isexport = false;
	}
	
	public void buildPageTotal(int pageSize,long rows){
		if(rows % pageSize == 0){
			this.pageTotal =  (int)rows / pageSize;
		}else{
			this.pageTotal =  (int)rows / pageSize + 1;
		}
	}
	
	private int builderPageTotal(int pageSize,long rows){
		if(rows % pageSize == 0){
			return (int)rows / pageSize;
		}else{
			return (int)rows / pageSize + 1;
		}
	}

	
	

	

	public boolean isIsexport() {
		return isexport;
	}

	public void setIsexport(boolean isexport) {
		this.isexport = isexport;
	}

	public int getPageNow() {
		return pageNow;
	}


	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}


	public int getPageSize() {
		return pageSize;
	}


	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}


	public long getRows() {
		return rows;
	}


	public void setRows(long rows) {
		this.rows = rows;
	}


	public int getPageTotal() {
		return pageTotal;
	}


	public void setPageTotal(int pageTotal) {
		this.pageTotal = pageTotal;
	}


	public List<T> getList() {
		return list;
	}


	public void setList(List<T> list) {
		this.list = list;
	}

	public T getParams() {
		return params;
	}

	public void setParams(T params) {
		this.params = params;
	}

	@Override
	public String toString() {
		return JsonUtil.objectToJson(this);
	}
	
	

}
